package com.ewit.colourlifepm.ui.contacts;

import java.util.HashMap;

import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract;

public class ContactGroup extends android.content.ContextWrapper {

	public ContactGroup(Context base) {
		super(base);
	}

	public HashMap<String, String> GetGroupReference() {
		HashMap<String, String> map = new HashMap<String, String>();

		Cursor GroupMembershipCursor = getContentResolver().query(
				ContactsContract.Groups.CONTENT_URI,
				new String[]{ContactsContract.Groups._ID,
						ContactsContract.Groups.TITLE}, null, null, null);

		if (GroupMembershipCursor.moveToFirst()) {
			do {

				String groupSourceID = GroupMembershipCursor
						.getString(GroupMembershipCursor
								.getColumnIndex(ContactsContract.Groups._ID));
				String groupTitle = GroupMembershipCursor.getString(
						GroupMembershipCursor
								.getColumnIndex(ContactsContract.Groups.TITLE))
						.toUpperCase();

				// String groupNotes =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.NOTES));
				// String groupSYSTEM_ID =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.SYSTEM_ID));
				// String groupSUMMARY_COUNT =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.SUMMARY_COUNT));
				// String groupSUMMARY_WITH_PHONES =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.SUMMARY_WITH_PHONES));
				// String groupGROUP_VISIBLE =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.GROUP_VISIBLE));
				// String groupDELETED =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.DELETED));
				// String groupSHOULD_SYNC =
				// GroupMembershipCursor.getString(GroupMembershipCursor.getColumnIndex(ContactsContract.Groups.SHOULD_SYNC));

				// Log.i("groupSourceID", groupSourceID);
				// Log.i("groupTitle", groupTitle);
				// Log.i("groupNotes", groupNotes);
				// Log.i("groupSYSTEM_ID", groupSYSTEM_ID);
				// Log.i("groupSUMMARY_COUNT", groupSUMMARY_COUNT);
				// Log.i("groupSUMMARY_WITH_PHONES", groupSUMMARY_WITH_PHONES);
				// Log.i("groupGROUP_VISIBLE", groupGROUP_VISIBLE);
				// Log.i("groupDELETED", groupDELETED);
				// Log.i("groupSHOULD_SYNC", groupSHOULD_SYNC);

				map.put(groupSourceID, groupTitle);
			} while (GroupMembershipCursor.moveToNext());
		}

		GroupMembershipCursor.close();

		return map;
	}
}
